import { Component, OnInit } from '@angular/core';
// 导入表单相关：表单验证、表单构建、表单组
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { NzMessageService } from 'ng-zorro-antd';
import { TokenService } from 'src/app/core/service/token.service';

@Component({
  selector: 'app-idap-config',
  templateUrl: './idap-config.component.html',
  styleUrls: ['./idap-config.component.scss']
})
export class IdapConfigComponent implements OnInit {

  portNumber = 389;
  idapConfigForm: FormGroup;
  
  constructor(
    private fb: FormBuilder,
    private message: NzMessageService,
    private tokenService: TokenService
  ) {
    this.idapConfigForm = fb.group({
      serverName: [null, Validators.required],
      ladpType: [null, Validators.required],
      hostName: [null, Validators.required],
      port: [null, Validators.required],
      baseDn: [null, Validators.required],
      usersDn: [null, Validators.required]
    });
    console.log(this.idapConfigForm.valid);
  }
  // 弹框
  createMessage(type: string, content?: string): void {
    if (type === 'success') {
      this.message.create(type, `配置成功!`, { nzDuration: 5000 });
    } else if (type === 'error') {
      this.message.create(type, `表单校验失败!请检查后重新提交`, { nzDuration: 5000 });
    }
  }
  addIdapConfig() {
console.log('ldapPost', this.idapConfigForm);
  }
  private postServer() {

  }
  ngOnInit() {
  }

}
